using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace proyecto35.admin.temporadas_dir
{
    public partial class borrado_temporada : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request["idb"] != null)
                {
                    List<articulos> lista = new List<articulos>();
                    lista = articulos.getListarticulosByidtemporadas(sf.entero(Request["idb"]));
                    Repeater1.DataSource = lista;
                    Repeater1.DataBind();
                }
            }
        }

        protected void btneliminar_Click(object sender, EventArgs e)
        {
            List<articulos> lista = new List<articulos>();
            lista = articulos.getListarticulosByidtemporadas(sf.entero(Request["idb"]));


            foreach (articulos art in lista)
            {
                art.outlet = true;
                art.idtemporadas = 0;
                articulos.Update(art);
                //List<coloresarticulos> listacolores = new List<coloresarticulos>();
                //listacolores = coloresarticulos.getListcoloresarticulosByidarticulos(art.idarticulos);
                //foreach (coloresarticulos col in listacolores)
                //{
                //  //  coloresarticulos.Delete(col.idcoloresarticulos);
                //}

                //List<tallasarticulos> listatallas = new List<tallasarticulos>();
                //listatallas = tallasarticulos.getListtallasarticulosByidarticulos(art.idarticulos);
                //foreach (tallasarticulos talla in listatallas)
                //{
                //    tallasarticulos.Delete(talla.idtallasarticulos);
                //}



                //if (System.IO.File.Exists(Server.MapPath(art.imagen)))
                //    System.IO.File.Delete(Server.MapPath(art.imagen));
                //articulos.Delete(art.idarticulos);
            }
            temporadas.Delete(sf.entero(Request["idb"]));
            btneliminar.Visible = false;
            Repeater1.Visible = false;
            butCancelar.Text = "Completado, pulse para volver";
        }

        protected void butCancelar_Click(object sender, EventArgs e)
        {
            Response.Redirect("listado_temporadas.aspx");
        }
    }
}
